package ModelLayer;
import java.util.ArrayList;



public class StudentContainer
{
    
    private ArrayList<Student> students;

    /**
     * Constructor
     * Initializa the instance fields
     */
    public StudentContainer()
    {
        students = new ArrayList<Student>();
    }

    /**
     * The method that add a new student  
     */
    public void addStudent(Student newStudent)
    {
        
        students.add(newStudent);
    }
    public Student findStudent(int id)
    {
        boolean found = false;
        int index = 0;
        while(index < students.size() && !found)
        {
            Student s = students.get(index);
            if(s.getId() == id)
            {
                found = true;
            }
            else{
                index++;
            }
        }//end while
        if(found){
            return students.get(index);
        }
        else{
            return null;
        }
    }
}
